package org.martyn.danbodroid.gui.adapters;

import java.util.ArrayList;

import org.martyn.danbodroid.gui.PreviewPicture;
import org.martyn.danbooru.types.PostPicture;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class PreviewPictureAdapter extends BaseAdapter
{
	private Context context;
	private ArrayList<PostPicture> postPictures;

	/**
	 * Constructor voor de PostsListActivity
	 * 
	 * @param context
	 *            De PostListActivity Context
	 * @param postPictures
	 *            Alle PostPicture objecten die weergegeven moeten worden
	 */
	public PreviewPictureAdapter(
			Context context,
			ArrayList<PostPicture> postPictures)
	{
		this.context = context;
		this.postPictures = postPictures;
	}

	@Override
	public int getCount()
	{
		return postPictures.size();
	}

	@Override
	public Object getItem(int position)
	{
		return postPictures.get(position);
	}

	@Override
	public long getItemId(int position)
	{
		return position;
	}

	@Override
	public View getView(int position, View paramView, ViewGroup paramViewGroup)
	{
		PreviewPicture previewPicture = new PreviewPicture(
				context.getApplicationContext(), postPictures.get(position));

		return previewPicture;
	}
}
